Skip to content

Conversation

@saenyakorn
Copy link
Member

@saenyakorn saenyakorn commented Oct 21, 2025

What I did

Introduce DefinedUseQueryResult when passing initialData as a options. For exampale,

useQuery

// without initialData
const { data } = reactQueryClient.useQuery("/users", "$get", {}) 

type Data = typeof data //  { data: User, status: 200, format: 'json' } | undefined

// with initialData
const { data } = reactQueryClient.useQuery("/users", "$get", {}, { 
  initialData: {
    data: { ... },
    status: 200,
    format: 'json'
  }
}) 

type Data = typeof data // { data: User, status: 200, format: 'json' }

queryOptions

// without initialData
const options = reactQueryClient.useQuery("/users", "$get", {}) // UndefinedInitialDataOptions<{ users: { id: string; name: string }[]}>

const query = useQuery(options) // useQueryResult<{ users: { id: string; name: string }[]}>

type Data = typeof query.data  //  { data: User, status: 200, format: 'json' } | undefined

// with initialData

const options = reactQueryClient.useQuery("/users", "$get", {}) // DefinedInitialDataOptions<{ users: { id: string; name: string }[]}>

const query = useQuery(options) // DefinedUseQueryResult<{ users: { id: string; name: string }[]}>

type Data = typeof query.data // { data: User, status: 200, format: 'json' }

@saenyakorn saenyakorn changed the title [Feature] Introduce useQuery with DefinedUseQueryResult type [Feature] Introduce useQuery with DefinedUseQueryResult type and queryOptions with DefinedInitialDataOptions Oct 21, 2025
@changeset-bot
Copy link

changeset-bot bot commented Oct 21, 2025

🦋 Changeset detected

Latest commit: e535f40

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@softnetics/hono-react-query Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@saenyakorn saenyakorn merged commit 24c1693 into main Oct 21, 2025
1 check passed
@github-actions github-actions bot mentioned this pull request Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant